/*    */ package com.qmsk.business.member.custIntratnchannel.controller;
/*    */ 
/*    */ import com.qmsk.business.member.custIntratnchannel.dao.CustIntratnChannelDAO;
/*    */ import com.utils.gson.in.GsonHeadOneRow;
/*    */ import com.utils.web.RequestUtils;
/*    */ import com.utils.web.ResponseUtils;
/*    */ import java.util.Date;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import org.apache.log4j.Logger;
/*    */ import org.springframework.beans.factory.annotation.Autowired;
/*    */ import org.springframework.stereotype.Controller;
/*    */ import org.springframework.transaction.annotation.Transactional;
/*    */ import org.springframework.web.bind.annotation.PathVariable;
/*    */ import org.springframework.web.bind.annotation.RequestMapping;
/*    */ 
/*    */ @Controller
/*    */ @RequestMapping({"custIntratn"})
/*    */ public class CustIntratnChannelController
/*    */ {
/* 30 */   private static final Logger logger = Logger.getLogger(CustIntratnChannelController.class);
/*    */ 
/*    */   @Autowired
/*    */   private CustIntratnChannelDAO dao;
/*    */ 
/*    */   @Transactional
/*    */   @RequestMapping(value={"insert/custIntratn/openId/{openId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*    */   public void getListAll(@PathVariable("openId") String openId, HttpServletRequest request, HttpServletResponse response)
/*    */   {
/*    */     try
/*    */     {
/* 43 */       Integer chanalId = RequestUtils.getInt(request, "chanalId");
/* 44 */       if (chanalId == null) {
/* 45 */         ResponseUtils.setErrorMsgResponse("选择频道错误", response);
/* 46 */         return;
/*    */       }
/* 48 */       int flag = this.dao.checkExistByOpenIdAndChanalId(openId, chanalId);
/* 49 */       int nResult = 0;
/* 50 */       if (flag == 0) {
/* 51 */         Date now = new Date();
/* 52 */         String[] heads = { "channelId", "OpenID", "creatTime", "intratnTime" };
/* 53 */         Object[] datas = { chanalId, openId, now, now };
/* 54 */         GsonHeadOneRow g = new GsonHeadOneRow(heads, datas);
/* 55 */         nResult = this.dao.insertGsonHeadOneRow(g);
/* 56 */         if (nResult > 0) {
/* 57 */           this.dao.commit();
/* 58 */           ResponseUtils.setSuccessResponse(response);
/* 59 */           return;
/*    */         }
/*    */       }
/* 62 */       else if (flag == 1) {
/* 63 */         nResult = this.dao.updateIntratnTimeByOpenIdAndChanalId(openId, chanalId);
/* 64 */         if (nResult > 0) {
/* 65 */           this.dao.commit();
/* 66 */           ResponseUtils.setSuccessResponse(response);
/* 67 */           return;
/*    */         }
/*    */       }
/* 70 */       this.dao.rollback();
/* 71 */       ResponseUtils.setErrorMsgResponse("更新互动频道失败", response);
/*    */     }
/*    */     catch (Exception e) {
/* 74 */       logger.error(e.getMessage());
/* 75 */       this.dao.rollback();
/* 76 */       ResponseUtils.setErrorMsgResponse("更新互动频道失败", response);
/*    */     }
/*    */   }
/*    */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.member.custIntratnchannel.controller.CustIntratnChannelController
 * JD-Core Version:    0.5.3
 */